<template>
    <div class="pad">
        <!-- table start -->
        <tableDataEl
            :page.sync="page"
            :pageSize.sync="pageSize"
            :tableData="tableData.list"
            :tableLabel="tableLabel"
            :pageCount="tableData.rows"
            height="89vh"
            v-loading="loading"
            @handleDetail="handleDetail"
        />
        <!-- table end -->
        <!-- dialog start -->
        <el-dialog
            :visible.sync="isShowDialog"
            center
            title="详情"
            width="30%"
            v-el-drag-dialog
        >
            <el-form v-loading="detailLoading">
                <el-form-item label="运营商数量:">
                    <el-input disabled :value="detailData.agent_num" size="small"></el-input>
                </el-form-item>
                <el-form-item label="系统余额:">
                    <el-input disabled :value="detailData.balance" size="small"></el-input>
                </el-form-item>
                <el-form-item label='库存:'>
                    <el-table
                        :data="detailData.mate"
                        border
                        height="250px"
                    >
                        <el-table-column
                            label="物料名称"
                            prop="name"
                            align="center"
                        />
                        <el-table-column
                            label="期初配给"
                            prop="ration"
                            align="center"
                        />
                        <el-table-column
                            label="剩余库存"
                            prop="materiel_stock"
                            align="center"
                        />
                    </el-table>
                </el-form-item>
            </el-form>
        </el-dialog>
        <!-- dialog end -->
    </div>
</template>

<script>
    import tableDataEl from '@/views/Setup/common/table'
    export default {
        name: "throughdownList",
        components: {
            tableDataEl
        },
        data () {
            return {
                page: 1,
                pageSize: 8,
                tableData: {},
                tableLabel: [
                    {
                        label: '市代名称',
                        prop: 'company',
                        detail: true,
                        methodName: 'handleDetail'
                    },
                    {
                        label: '联系方式',
                        prop: 'phone'
                    },
                    {
                        label: '负责人',
                        prop: 'leader'
                    },
                    {
                        label: '地区',
                        prop: 'city'
                    },
                    {
                        label: '取消理由',
                        prop: 'reason'
                    },
                    {
                        label: '申请时间',
                        prop: 'create_time'
                    },
                    {
                        label: '审核时间',
                        prop: 'audit_time'
                    },
                    {
                        label: '审核人',
                        prop: 'audit_person'
                    }
                ],
                loading: false,
                isShowDialog: false,
                detailData: {},
                detailLoading: false
            }
        },
        methods: {
            async init () { //初始化
                this.loading = true;
                let res = await this.api.log_cancel_auditList({page: this.page, pageSize: this.pageSize});
                res.code ? this.tableData = res.data : this.$message(res.msg);
                this.loading = false;
            },
            async handleDetail (...value) { //详情
                this.isShowDialog = true;
                this.detailLoading = true;
                let res = await this.api.log_cancel_getCancelDetail({gid: value[1]['gid']});
                res.code ? this.detailData = res.data : this.$message(res.msg);
                this.detailLoading = false;
            }
        },
        mounted () {
            this.init()
        },
        watch: {
            page () {
                this.init()
            },
            pageSize () {
                this.init();
            }
        }
    }
</script>

<style scoped>
    .pad {
        padding: 10px;
    }
    .el-form-item {
        margin-bottom:0;
    }
</style>
